package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.HotSearchService;

import javax.annotation.Resource;

/**
 * 热门搜索
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/hot/search")
public class HotSearchController {

	@Autowired
	private HotSearchService hotSearchService;

	@ResponseBody
	@RequestMapping(value = "/create", method = { RequestMethod.POST })
	public Map<String,Object> create(@RequestParam(required = true) String name,
			@RequestParam(required = true) Integer times) {
		return hotSearchService.create(name, times);
	}

	@ResponseBody
	@RequestMapping(value = "/update", method = { RequestMethod.POST })
	public Map<String,Object> update(@RequestParam(required = true) String id,
			@RequestParam(required = false) String name, @RequestParam(required = false) Integer times) {
		return hotSearchService.update(id, name, times);
	}

	@ResponseBody
	@RequestMapping(value = "/select/all", method = { RequestMethod.GET })
	public Map<String,Object> selectAll(
			@RequestParam(required = false, defaultValue = "1") Integer currentPage,
			@RequestParam(required = false, defaultValue = "10") Integer pageSize) {
		return hotSearchService.selectAll(currentPage, pageSize);
	}

}
